<!DOCTYPE html>
<html>
<head>
    <title>Html5 Lesson 18 (CSS transition)</title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <style>
        header {
            background: #FFCC99;
            color: white;
            -moz-box-shadow: 0 2px 8px -3px rgba(0, 0, 0, .5), 0 1.4em 2em -0.7em rgba(255, 255, 255, .2) inset;
            -webkit-box-shadow: 0 2px 8px -3px rgba(0, 0, 0, .5), 0 1.4em 2em -0.7em rgba(255, 255, 255, .2) inset;
            box-shadow: 0 2px 8px -3px rgba(0, 0, 0, .5), 0 1.4em 2em -0.7em rgba(255, 255, 255, .2) inset;
            text-shadow: 1px 1px 1px #444;
        }

        header h1, header h2 {
            display: inline-block;
            padding: 12px 15px;
            font-size: 105%;
            line-height: 1;
            margin: 0;
        }

        header h1 {
            background: #FF9966;
        }

        .arrow-right {
            display: inline-block;
            width: 0;
            height: 0;
            border-top: 18px solid transparent;
            border-bottom: 18px solid transparent;
            border-left: 18px solid #FF9966;
            margin-bottom: -11px;
        }
        #content {

            -webkit-transition: margin-left 1s ease-in-out;
            -moz-transition: margin-left 1s ease-in-out;
            -o-transition: margin-left 1s ease-in-out;

            display: inline;
            height: 20px;
            background: red;
            color: white;
        }
        #content.left {
            margin-left: 0;
        }
        #content.right {
            margin-left: 780px;
        }
    </style>
</head>
<body>
<header>
    <h1>CSS过渡效果</h1>

    <div class="arrow-right"></div>
    <h2></h2>
</header>
<div id="content"></div>
<p id="log"></p>
<script>
    var content = document.querySelector('#content');
    content.innerHTML = '点击这儿试试';
    content.addEventListener('click', function() {
        window.console && console.log(this)
        if (this.className == "right") {
            this.className = "left";
        }
        else {
            this.className = 'right';
        }
    }, false);
</script>
</body>
</html>​